package com.xawl.service.impl;

import com.xawl.dao.QuestionMapper;
import com.xawl.pojo.Question;
import com.xawl.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class QuestionServiceImpl implements QuestionService {

    @Autowired
    QuestionMapper questionMapper;

    public Integer getTotal() {
        return questionMapper.getTotal();
    }

    public int addQuestion(Question question) {
        return questionMapper.addQuestion(question);
    }

    public int deleteQuestion(int q_id) {
        return questionMapper.deleteQuestion(q_id);
    }

    @Override
    public int deleteQuestions(Long[] ids) {
        return questionMapper.deleteQuestions(ids);
    }

    public int updateQuestion(Question question) {
        return questionMapper.updateQuestion(question);
    }

    @Override
    public Question findQuestionById(int id) {
        return questionMapper.findQuestionById(id);
    }

    @Override
    public List<Question> queryAll() {
        return questionMapper.queryAll();
    }

    public List<Question> searchCourse(String q_title) {
        String title = "%"+q_title+"%";
        List <Question> questionList = questionMapper.searchQuestion(title);
        return questionList;
    }
}
